package FilterDemo01;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class Listener implements HttpSessionListener {
    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        ServletContext context = httpSessionEvent.getSession().getServletContext();
        Integer onlinelistener = (Integer) context.getAttribute("onlinelistener");
        if (onlinelistener==null){
            onlinelistener=new Integer(1);
        }else{
            int count=onlinelistener.intValue();
            onlinelistener=new Integer(count+1);

        }
        context.setAttribute("onlinelistener",onlinelistener);
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {

    }
}
